<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.longtop.com/intelliweb" prefix="e"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<e:View id="view">
    <script type="text/javascript" src="<c:url value='/scripts/global.js'/>"></script>
	<script type="text/javascript" src="<c:url value='/scripts/skin.js'/>"></script>
    <script type="text/javascript">SkinUtil.getSkin();</script>
    <script type="text/javascript">SkinUtil.getModuleSkin();</script>
    
	<div id="Invisual Controls" style="min-height: 40px; background-color: LemonChiffon;" >
		<e:Dataset id="Dataset_FlowInstance" datasetDefinition="DatasetDefinition_sys.dsd" datasetRef="Dataset_FlowInstance" pageSize="10" loadDataCommand="Command_Load" allowMultiSelect="false">
			<e:Field name="instanceId" dataType="string" label="实例ID" maxLength="32" visible="false"/>
			<e:Field name="launchUserName" dataType="string" label="启动人" maxLength="100" />
			<e:Field name="launchTime" dataType="timestamp" label="启动时间" maxLength="11" />
			<e:Field name="launchUserId" dataType="string" label="启动人ID" maxLength="32"/>
			<e:Field name="launchOrgId" dataType="string" label="启动人机构ID" maxLength="32" visible="false"/>
			<e:Field name="launchOrgName" dataType="string" label="启动人机构名称" maxLength="100" />
			<e:Field name="status" dataType="string" label="流程状态" maxLength="1"  dropDown="ListDropDown_Status"/>
			<e:Field name="templateId" dataType="string" label="流程模板类型" maxLength="32" dropDown="DataDropDown_Template"/>
			<e:Field name="nodeName" dataType="string" label="当前处理结点" maxLength="32" />
			<e:Field name="nodeUrl" dataType="string" label="节点URL" maxLength="32" />
			<e:Field name="viewUrl" dataType="string" label="流程URL" maxLength="32" />
		</e:Dataset>
		
		<e:Dataset id="Dataset_FlowTemplate" datasetDefinition="DatasetDefinition_sys.dsd" datasetRef="Dataset_FlowTemplate" pageSize="10" loadDataCommand="Command_Load" allowMultiSelect="false">
				<e:Field name="templateId" dataType="string" label="流程ID" maxLength="32" />
				 <e:Field name="templateName" dataType="string" label="流程名称" maxLength="100" />
				 <e:Field name="viewUrl" dataType="string" label="流程查看地址" maxLength="200" />
				 <e:Field name="remark" dataType="string" label="备注" maxLength="200" />
		</e:Dataset>
		
		<e:Command id="Command_Search" action="com.longtop.framework.sys.flow.web.FlowInstanceListAction" method="searchFlowInstance" submitForm="true" submitFormScope="all" validateRequired="true">
			<e:DatasetInfo name="DatasetInfo2" dataset="Dataset_FlowInstance" alwayRefreshClient="true"></e:DatasetInfo>
			<e:Parameter name="templateId" value="${param.templateId}"></e:Parameter>
		</e:Command>
		<e:Command id="Command_Load" action="com.longtop.framework.sys.flow.web.FlowInstanceListAction" method="loadFlowInstance" submitForm="true" submitFormScope="all" showHintInfoOnSuccess="false">
			<e:DatasetInfo name="DatasetInfo3" dataset="Dataset_FlowInstance" alwayRefreshClient="true"></e:DatasetInfo>
			<e:Parameter name="templateId" value="${param.templateId}"></e:Parameter>
		</e:Command>
		
		<e:ListDropDown id="ListDropDown_Status" autoDropDown="true" fixed="true">
			<e:ListDropDownItem name="ListDropDownItem1" label="已办结" value="1" />
			<e:ListDropDownItem name="ListDropDownItem2" label="未办结" value="0" />
		</e:ListDropDown>
		
		<e:ListDropDown id="ListDropDown_Relation" autoDropDown="true" fixed="true">
			<e:ListDropDownItem name="ListDropDownItem1" label="我的待办" value="1" />
			<e:ListDropDownItem name="ListDropDownItem2" label="我的申请" value="2" />
			<e:ListDropDownItem name="ListDropDownItem3" label="我参与过" value="3" />
		</e:ListDropDown>
		
		<e:DataDropDown id="DataDropDown_Template" dataset="Dataset_FlowTemplate" visibleFields="templateName"
				codeField="templateId" textField="templateName" autoDropDown="true" fixed="true" showColumnHeader="false" >
		</e:DataDropDown>
		
	</div>

<body>
	<e:Page id="ePage" action="com.longtop.framework.sys.flow.web.FlowInstanceListAction" style="min-height: 80px; width: 100%; height: 100%;" onAfterLoadPage="ePage_onAfterLoadPage()">
		<table style="width: 100%; height: 100%;" border="0" cellpadding="0" cellspacing="0" width="100%" align="center">
			<tr>
				<td align="left" valign="top">
					<e:Panel id="Panel_Search" style="width: 285px; height: 100%" caption="查询条件" captionIcon="/images/query_win.gif" captionStyle="color:#888888" allowFold="true">
						<table style="text-align: left; width: 100%;" border="0" cellpadding="3" cellspacing="3" width="100%" align="center">
							<tr>
								<td align="right">
									<e:Label id="Label_launchUserName" caption="流程申请人"></e:Label>
								</td>
								<td>
									<e:Text id="Text_Launcher" style="width:169px;"></e:Text>
								</td>
							</tr>
							<tr>
								<td align="right">
									<e:Label id="Label_Relation" caption="流程关系"></e:Label>
								</td>
								<td>
									<e:Text id="Text_Relation" style="width:169px;" dropDown="ListDropDown_Relation" value="1"></e:Text>
								</td>
							</tr>
							<tr>
								<td align="right">
									<e:Label id="Label_Status" caption="流程状态"></e:Label>
								</td>
								<td>
									<e:Text id="Text_Status" style="width:169px;" dropDown="ListDropDown_Status"></e:Text>
								</td>
							</tr>
							<tr>
								<td><e:Text id="Text_TemplateId" value="${param.templateId}" style="width:0px;" visible="false"></e:Text></td>
								<td>
									<e:Button id="Button_Search" style='height: 22px; width: 70px' caption="查询"  icon="/images/query.gif" onClick="Button_Search_onClick()"></e:Button>
								</td>
							</tr>
						</table>
					</e:Panel>
				</td>
				<td valign="top" width="100%">
					<e:Panel id="Panel_Result" style="width: 100%; height: 100%" captionStyle="color:#888888" caption="查询结果列表" captionIcon="/images/list_win.gif">
						<table style="text-align: left; width: 100%;" border="0" cellpadding="3" cellspacing="3" >
							<tr>
								<td>
									<table style="text-align: left; width: 100%;" border="0" cellpadding="0" cellspacing="0">
										<tr>
											<td height="27px" width="1%">
												<e:RecordNavigator id="RecordNavigator_Instance" dataset="Dataset_FlowInstance" showNavigatorButton="false">
													<e:RecordButton id="RecordButton_Launch" label="提出申请" onClick="RecordButton_Launch_onClick()" icon="/images/list_win.gif" ></e:RecordButton>
													<e:RecordButton id="RecordButton_ViewInstance" label="查看流程" onClick="RecordButton_ViewInstance_onClick()" icon="/images/list_win.gif" ></e:RecordButton>
													<e:RecordButton id="RecordButton_DoFlow" label="处理流程" onClick="RecordButton_DoFlow_onClick()" icon="/images/list_win.gif" ></e:RecordButton>
												</e:RecordNavigator>
											</td>
											<td align="left" width="99%"><e:PageNavigator id="PageNavigator_Instance" dataset="Dataset_FlowInstance" showRecordNum="true"></e:PageNavigator></td>
										</tr>
									</table>
								</td>
							</tr>
							<tr>
								<td>
									<e:Grid id="Grid_Result" style="width: 100%; height: 400px;" showIndex="false" dataset="Dataset_FlowInstance" readOnly="true" onDblClick="RecordButton_DoFlow_onClick()">
										<e:Column name="instanceId" label="实例ID" field="instanceId"  visible="false"></e:Column>
										<e:Column name="templateId"      label="流程类型"      field="templateId"  ></e:Column>
										<e:Column name="launchUserId"        label="申请员工号"        field="launchUserId"        ></e:Column>
										<e:Column name="launchUserName"        label="申请员工"        field="launchUserName"      ></e:Column>
										<e:Column name="launchTime"      label="申请时间"      field="launchTime"     ></e:Column>
										<e:Column name="launchOrgName" label="申请人所在机构" field="launchOrgName"  ></e:Column>
										<e:Column name="status"          label="流程状态"      field="status"   ></e:Column>
										<e:Column name="nodeName"        label="当前处理节点"   field="nodeName"    ></e:Column>
									</e:Grid>
								</td>
							</tr>
						</table>
					</e:Panel>
				</td>
			</tr>
	    </table>
	</e:Page>
</body>
</e:View>
</html>

<script type="text/javascript">
	
//init
function ePage_onAfterLoadPage(){
}

//查询
function Button_Search_onClick(){
    Command_Search.execute();
	if($J("Text_Relation").getValue() == 1){
		$J("RecordNavigator_Instance").getRecordButtonById("RecordButton_DoFlow").setEnabled("true");
	}else {
		$J("RecordNavigator_Instance").getRecordButtonById("RecordButton_DoFlow").setEnabled("false");
	}
}

//发起流程
function RecordButton_Launch_onClick(){
	var path = "/jsp/framework/sys/flow/flowLeaveLaunch.jsp";
	parent.TabUtil.openTab("leaveLaunch","提出申请",path);
}

//查看流程
function RecordButton_ViewInstance_onClick(){
	var dataset_Instance = $J("Dataset_FlowInstance");		//取得dataset
	var record = dataset_Instance.getCurrentRecord();	//取得当前record
	if(record) { 
		var instanceId = record.getString("instanceId");			//取得实例id
		var viewUrl = record.getString("viewUrl");
	
		var path = viewUrl + "?instanceId=" + instanceId;
		openTab('view_' + instanceId, '查看流程', path);
	}
}

//处理流程
function RecordButton_DoFlow_onClick(){
	if($J("Text_Relation").getValue() != 1){
		MsgBox.showInfoMsg("选择我的待办，才能进行流程处理操作!");
		return;
	}

	var dataset_Instance = $J("Dataset_FlowInstance");		//取得dataset
	var record = dataset_Instance.getCurrentRecord();	//取得当前record
	if(record) { 
		var instanceId = record.getString("instanceId");			//取得实例id
		var nodeUrl = record.getString("nodeUrl");
	
		var path = nodeUrl + "?instanceId=" + instanceId;
		openTab('do_' + instanceId, '处理流程', path);
	}
}
</script>